
#include "Iterator.h"
#include "Aggregator.h"
#include <memory>
#include <iostream>

using namespace npIterator;
using namespace std;


void doIterator()
{
    //set iterator
    //end
    //深入学习迭代器模式

    shared_ptr<Aggregator> aggregator(new Aggregator());
    aggregator->push(Stuff("Good "));
    aggregator->push(Stuff("weather "));
    aggregator->push(Stuff("today.--------"));

    aggregator->pop(aggregator->count() - 1);

    aggregator->push(Stuff("today. Isn\'t it?"));
    
    shared_ptr<Iterator> i = aggregator->createIterator(weak_ptr<Aggregator>(aggregator)).lock();

    cout << endl;
    for (Stuff s = i->first(); !i->isLast() ; s = i->next())
    {
        s.say();
    }
    cout << endl;
}